package com.moka.db;

import java.util.ArrayList;
import java.util.List;

import com.moka.db.test.Student;

import android.content.Context;

public class Configuration {

	public static int getOldVersion(Context context,String dbName) {
		
		DatabaseVersionManager dvm = new DatabaseVersionManager(context);
		
		return dvm.getVersion(dbName);
		
	}

	public static int getNewVersion(String dbName) {
		
		int maxVersion = 0;
		
		List<Class<?>> list = getDatabaseEntityList(dbName);
		
		for(Class<?> clazz : list){
			
			try {
				
				DatabaseEntity entity = (DatabaseEntity)clazz.newInstance();
				
				if(maxVersion < entity.getMaxVersion()){
					
					maxVersion = entity.getMaxVersion();
					
				}
				
			} catch (Exception e) {
				
				e.printStackTrace();
				
			}
			
		}
		
		return maxVersion;
		
	}

	public static List<Class<?>> getDatabaseEntityList(String dbName) {
		
		List<Class<?>> list = new ArrayList<Class<?>>();
		
		list.add(Student.class);
		
		return list;
		
	}

	
	
}
